﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace MockingBird.Simulator.Interceptors.Wcf.Contracts
{
    [ServiceContract(Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface IOneWay
    {
        [OperationContract(IsOneWay = true, Action = "*")]
        void ProcessMessage(Message message);
    }

    [ServiceContract(Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Required)]
    public interface IOneWaySession
    {
        [OperationContract(IsOneWay = true, Action = "*")]
        void ProcessMessage(Message message);
    }

    [ServiceContract(Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Required, CallbackContract = typeof(IOneWay))]
    public interface IOneWayDuplex
    {
        [OperationContract(IsOneWay = true, Action = "*")]
        void ProcessMessage(Message message);
    }

    [ServiceContract(Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface ITwoWay
    {
        [TransactionFlow(TransactionFlowOption.Allowed)]
        [OperationContract(IsOneWay = false, Action = "*", ReplyAction = "*")]
        Message ProcessMessage(Message message);
    }

    [ServiceContract(Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface ITwoWayVoid
    {
        [TransactionFlow(TransactionFlowOption.Allowed)]
        [OperationContract(IsOneWay = false, Action = "*", ReplyAction = "*")]
        void ProcessMessage(Message message);
    }

    [ServiceContract(Name="IOneWay", Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface IOneWayAsync
    {
        [OperationContract(AsyncPattern = true, IsOneWay = true, Action = "*")]
        IAsyncResult BeginProcessMessage(Message message, AsyncCallback callback, object state);
        void EndProcessMessage(IAsyncResult result);
    }

    [ServiceContract(Name="IOneWaySession", Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Required)]
    public interface IOneWaySessionAsync
    {
        [OperationContract(AsyncPattern = true, IsOneWay = true, Action = "*")]
        IAsyncResult BeginProcessMessage(Message message, AsyncCallback callback, object state);
        void EndProcessMessage(IAsyncResult result);
    }

    [ServiceContract(Name="IOneWayDuplex", Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Required, CallbackContract = typeof(IOneWay))]
    public interface IOneWayDuplexAsync
    {
        [OperationContract(AsyncPattern = true, IsOneWay = true, Action = "*")]
        IAsyncResult BeginProcessMessage(Message message, AsyncCallback callback, object state);
        void EndProcessMessage(IAsyncResult result);
    }

    [ServiceContract(Name="ITwoWay", Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface ITwoWayAsync
    {
        [TransactionFlow(TransactionFlowOption.Allowed)]
        [OperationContract(AsyncPattern = true, IsOneWay = false, Action = "*", ReplyAction = "*")]
        IAsyncResult BeginProcessMessage(Message message, AsyncCallback callback, object state);
        Message EndProcessMessage(IAsyncResult result);
    }

    [ServiceContract(Name="ITwoWayVoid", Namespace = "urn:mockingbird.simulator:contracts", SessionMode = SessionMode.Allowed)]
    public interface ITwoWayVoidAsync
    {
        [TransactionFlow(TransactionFlowOption.Allowed)]
        [OperationContract(AsyncPattern = true, IsOneWay = false, Action = "*", ReplyAction = "*")]
        IAsyncResult BeginProcessMessage(Message message, AsyncCallback callback, object state);
        void EndProcessMessage(IAsyncResult result);
    }
}
